package Underworld_Survival;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

// 效果记录容器
public class EffectRecord implements Serializable {
    private final String sourceId; // 效果来源标识（如"飞剑"）
    protected final Map<AttributeType, EffectValue> modifications;

    public EffectRecord(String sourceId, Map<AttributeType, EffectValue> mods) {
        this.sourceId = sourceId;
        this.modifications = new HashMap<>(mods);
    }

    // 获取当前角色上下文下的实际数值
    public Map<AttributeType, Float> resolveValues(Role context) {
        Map<AttributeType, Float> resolved = new HashMap<>();
        modifications.forEach((type, effect) -> {
            resolved.put(type, effect.getValue(context));
        });
        return resolved;
    }

    public String getSourceId(){
        return sourceId;
    }

    public Map<AttributeType, EffectValue> getModifications() {
        return modifications;
    }

}
